package com.sta3d.Stub;

import com.sta3d.serveratm.ServerPerformer;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: Stasico
 * Date: 22.01.14
 * Time: 0:08
 * To change this template use File | Settings | File Templates.
 */
public class ServerSideStub {
    public static ServerPerformer getServerPerformer() throws IOException {
        ServerSocket serverSocket = new ServerSocket(7001);

        Socket socket = new Socket("localhost", 7001);
        OutputStream outputS = socket.getOutputStream();
        DataOutputStream outputData = new DataOutputStream(outputS);
        String showData = new SimpleDateFormat("hh.mm.ss").format(new Date());
        outputData.writeUTF("[" + showData + "] <" + 1234 + ">*<" + "4769304941841937" + "> # " + "want " + "0000" + "            ");

        Socket socketPerformer = serverSocket.accept();
        socket.close();
        return new ServerPerformer(socketPerformer);
    }
}
